
TRIGGER PROCEDURE FOR WRITE OF PTS_DET OLD BUFFER OLD_PTS_DET.

{mfdeclre.i }
define new shared work-table wf_old_pts_det like pts_det.

/* fdn 2004/10/28 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "pts_det" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(pts_det), input "pts_det").

    if not can-find ( first dt_mstr where dt_table = "pts_det" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_pts_det ) then do:
        create wf_old_pts_det.
        if recid(wf_old_pts_det)= -1 then .
    end.
    
    buffer-copy old_pts_det to wf_old_pts_det no-error.

    for each dt_mstr no-lock where dt_table = "pts_det" and dt_type = "MOD" :
    
        case dt_field :

            when "pts_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_part, input pts_det.pts_part,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_par" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_par, input pts_det.pts_par,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_sub_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_sub_part, input pts_det.pts_sub_part,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_qty_per" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_pts_det.pts_qty_per), input string(pts_det.pts_qty_per),
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_rmks" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_rmks, input pts_det.pts_rmks,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_cmtindx" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_pts_det.pts_cmtindx), input string(pts_det.pts_cmtindx),
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_user1, input pts_det.pts_user1,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_user2, input pts_det.pts_user2,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts_userid, input pts_det.pts_userid,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts_mod_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_pts_det.pts_mod_date), input string(pts_det.pts_mod_date),
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

            when "pts__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_pts_det.pts__qadc01, input pts_det.pts__qadc01,
                    input recid(pts_det), input pts_det.pts_part, input pts_det.pts_par, input pts_det.pts_sub_part, input "",
                    input "", input "", input "", input "").

        end.

    end.
end.

{hkdttrans.i}
